<?php

namespace App\Services;

use App\Models\Link;

class LinkService
{

    public function getList()
    {
        return Link::orderBy('list_order')->orderBy('id')->get()->toArray();
    }

    public function add(array $data)
    {
        $link = new Link($data);
        $link->save();
    }

    public function find(int $id)
    {
        return Link::findOrFail($id);
    }

    public function edit(array $data)
    {
        $link = Link::find($data['id']);
        $link->fill($data);
        $link->save();
    }

    public function del(int $id)
    {
        Link::destroy($id);
    }

}
